package main

import (
	"github.com/gpmgo/gopm/modules/log"
	"golang.org/x/net/context"
	"google.golang.org/grpc"
	"grpc/proto"
	"os"
)

const (
	address     = "127.0.0.1:50051"
	defaultName = "world"
)

type client struct {
}

func (c *client) SayHello(ctx context.Context, in *proto.HelloRequest, opts ...grpc.CallOption) (*proto.HelloReply, error) {
	panic("implement me")
}

func (c *client) ListFeatures(ctx context.Context, in *proto.Rectangle, opts ...grpc.CallOption) (proto.Greeter_ListFeaturesClient, error) {
	panic("implement me")
}

func (c *client) RecordRoute(ctx context.Context, opts ...grpc.CallOption) (proto.Greeter_RecordRouteClient, error) {
	panic("implement me")
}

func (c *client) RouteChat(ctx context.Context, opts ...grpc.CallOption) (proto.Greeter_RouteChatClient, error) {
	panic("implement me")
}

func main() {
	conn, err := grpc.Dial(address, grpc.WithInsecure())
	if err != nil {
		log.Fatal("did not connect:%v", err)
	}
	defer conn.Close()

	c := proto.NewGreeterClient(conn)

	name := defaultName
	if len(os.Args) > 1 {
		name = os.Args[1]
	}

	r, err := c.SayHello(context.Background(), &proto.HelloRequest{Message: name}) //客户端和服务端通过string 交互

	if err != nil {
		log.Fatal("could not greet: %v", err)
	}
	log.Fatal("####### get server Greeting response: %s", r.Name)
//https://blog.csdn.net/wdy_yx/article/details/74203178
}
